document.onkeydown = function(e)
{
	var ev = e || window.event;
	var obj = ev.target || ev.srcElement; // 获取事件源 
	var type = obj.type || obj.getAttribute("type"); // 获取事件源类型

	if(ev.keyCode == 8 && (type != "password" && type != "text" && type != "textarea")) // 排除后退键
	{
		try
		{
			ev.returnValue = false;
			ev.preventDefault();
		}
		catch(e){};
	}
}

window.onbeforeunload = function()
{
	var n = window.event.screenX - window.screenLeft;
	var b = n > document.documentElement.scrollWidth - 20;

	if((b && window.event.clientY < 0) || window.event.altKey || window.event.ctrlKey)
	{
		location = "exit";
	}
};

// 异步调用方法
ajaxRequest = function(param, successCallback, faildCallback)
{
    var sucFunCtx = arguments[3] || window;
    var faiFunCtx = arguments[4] || window;
	
	$.ajax
	({
		type : param.method || "post",
		dataType : param.dataType || "json",
		data : param.reqData,
		url : param.reqUrl,
		success : function(d, s)
		{
			if(successCallback)
			{
				successCallback.call(sucFunCtx, d, s);
			}
		},
		error : function(xmlobj, state, errorThrown)
		{
			if(faildCallback)
			{
				faildCallback.call(faiFunCtx, xmlobj);
			}
		}
	});
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.replaceAll = function(src, dest)
{
    return this.replace(new RegExp(src, "gm"), dest); 
}

String.prototype.encodeUriParam = function()
{
    return this ? encodeURIComponent(encodeURI(encodeURI(this))) : "";
}

String.prototype.decodeUriParam = function()
{
	return this ? decodeURIComponent(decodeURI(this)) : "";
}